# coding:utf-8


def cypherToPulse(string,toMemeory=False,outputFileName=""):
    str_len = len(string)
    print str_len
    index = 0
    str_temp = ""
    if toMemeory:
        while index < str_len:
            if string[index] == '0':
                str_temp += "00000000"
                index += 1
            else:
                str_temp += string[index:(index+8)] if index+8 < index else string[index:str_len]
                index +=8
        return str_temp
    else:
        # 保存到文件当中
        output_file = open("")
        while index < str_len:
            if len(str_temp)>=4000 or index>=str_len:
                output_file.write(str_temp)
                str_temp = ""
            else:
                if string[index] == '0':
                    str_temp += "00000000"
                    index += 1
                else:
                    str_temp += string[index:(index+8)] if index+8 < index else string[index:str_len]
                    index +=8
